package com.eastcom.dataquality.dc.timerTask;

import java.util.Date;

import org.apache.log4j.Logger;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;

import com.eastcom.dataquality.core.util.CharliDate;
import com.eastcom.dataquality.dc.collect.AbsenceAbnormalProcesor;

public class BackCollectRoutine implements BeanFactoryAware{

	private BeanFactory beanFactory;
	
	private static Logger logger=Logger.getLogger(BackCollectRoutine.class);
	
	public void doRoutine(){
		logger.info("BackCollectRoutine start routing...");
		Date now=new Date();
		Date startDate=CharliDate.getStartTimeOfDaysApartCurrentDay(now, -2);
		Date endDate=CharliDate.getStartTimeOfDaysApartCurrentDay(now, 0);
		AbsenceAbnormalProcesor absenceProcessor=(AbsenceAbnormalProcesor)beanFactory.getBean("absenceProcessor");
		absenceProcessor.process(startDate, endDate);
		logger.info("BackCollectRoutine end routing");
	}

	public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
		this.beanFactory=beanFactory;
	}
}
